﻿using System.Collections.Generic;
using System.Web.UI;
using Ext.Net;
using KamLib;


namespace WebPoligon
{
    public partial class FieldBoxPage : Page
    {

        static FieldBoxPage() { UserUIL.NewFields(); }

        [DirectMethod]
        public object GetUsers(string action, Dictionary<string, object> extraParams)
        {
            //var userId = -1;
            //var prms = new StoreRequestParameters(extraParams);
            //var filter = prms.Filter;
            //if (filter.Length > 0 && filter[0].Property == "UserId")
            //{
            //    userId = Convert.ToInt32(filter[0].Value);
            //}

            return new[]
            {
                new User(1, "Mike", "Shpion"),
                new User(2, "Alis", "Shmelis"),
                new User(3, "Djon", "Pedgo"),
                new User(4, "Alex", "Sars"),
                new User(5, "Bill", "Smitt"),
            };
        }

        public new class User
        {
            public User(int id, string firstName, string lastName)
            {
                ID = id;
                FirstName = firstName;
                LastName = lastName;
                P = new PClass { P1 = 1, P2 = 2, P3 = 3, P4 = 4 };
            }

            public int ID { get; set; }
            public string FirstName { get; set; }
            public string LastName { get; set; }
            public PClass P { get; private set; }


            public class PClass
            {
                public int P1 { get; set; }
                public int P2 { get; set; }
                public int P3 { get; set; }
                public int P4 { get; set; }
            }
        }
    }
}